﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UCL;
using UCL.Forms;
using UCL.Data;

namespace DBKit5
{
    /// <summary>
    /// 脚本分发
    /// <remarks>1.0.0 2013-10-17 sutroon</remarks>
    /// </summary>
    public partial class frmScriptDistribute : Form
    {
        AppDataHelper adh;
        public frmScriptDistribute()
        {
            InitializeComponent();
        }

        private void frmScriptDistribute_Load(object sender, EventArgs e)
        {
            adh = new AppDataHelper();
            ucConnectionSelector1.LoadData(adh.SelectDataTable("tConnections", "", "ID, Name"));
        }

        private void btnRun_Click(object sender, EventArgs e)
        {
            if (tbSql.TextLength == 0 || ucConnectionSelector1.CheckedItemsCount == 0) return;
            string msg = adh.RunDistributeScript(ucConnectionSelector1.GetCheckedValues(a => a.Name), tbSql.Text);
            MessageBox.Show(msg == "SUCCESS" ? "执行成功!" : msg);
        }
    }
}
